import multiprocessing
import time
from multiprocessing import Process

from app.socket_client import SocketClient
from app.yolo_detect import Detect


client = SocketClient('127.0.0.1', 8888)

detect = Detect("/home/uds/code/px4_yolov8/app/models/best.pt",client)

threadRunning=True


queue_socket_to_detect = multiprocessing.Queue()


def detectRun(queue):
    detect.start(queue)


def start():
    threadRunning = True
    detectThread = Process(target=detectRun, args=(queue_socket_to_detect,))
    detectThread.start()



    while threadRunning:

        try:
            time.sleep(1)
            # client.heatBeat()
            volt = 0.0  # Board.getBattery()/1000.0
            # client.sendShipInfo(json.dumps(mySerial.shipInfo))


        except KeyboardInterrupt:
            print('Stop UnmannedShip....')
            threadRunning = False
            break


if __name__ == '__main__':
    start()